package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description AlertDataController
 * @Author duzhengxu
 * @Date 2024-09-15
 */
@RestController
@RequestMapping("/alert-data")
@Api(tags = "管理端 - 报警数据相关接口")
@Slf4j
public class AlertDataController {

    @Autowired
    private AlertDataService alertDataService;

    /**
     * 分页查询报警数据
     * @param alertDataPageQueryDto
     * @return
     */
    @GetMapping("/pageQuery")
    @ApiOperation("分页查询报警数据")
    public ResponseResult<PageResponse<AlertDataVo>> page(AlertDataPageQueryDto alertDataPageQueryDto) {
        log.info("分页查询报警数据,参数为:{}",alertDataPageQueryDto);
        PageResponse<AlertDataVo> pageResponse = alertDataService.page(alertDataPageQueryDto);
        return ResponseResult.success(pageResponse);
    }

    /**
     * 处理设备报警数据
     * @param id
     * @return
     */
    @PutMapping("/handleAlertData/{id}")
    @ApiOperation("处理设备报警数据")
    public ResponseResult handleAlertData(@PathVariable Long id,
                                          @RequestBody AlertDataHandleDto alertDataHandleDto){
        log.info("处理设备报警数据,参数为报警数据id:{},alertDataHandleDto:{}",id,alertDataHandleDto);
        alertDataService.handleAlertData(id,alertDataHandleDto);
        return ResponseResult.success();
    }
}
